﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Threading;

namespace WinMineGoogleTranslator
{
	static class Program
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main()
		{
			// Try to create a mutex checking if it exists or not with the third parameters
			bool firstInstance;
			Mutex mutex = new Mutex(false, "Local\\" + MainForm.ApplicationName, out firstInstance);

			if (firstInstance == false)
			{
				// Advise the user with a message box
				MessageBox.Show("O aplicativo já está rodando. Impossível rodar uma segunda instância!",
				String.Format("{0} version: {1} - Error", MainForm.ApplicationName, MainForm.ApplicationVersion.ToString()),
				MessageBoxButtons.OK, MessageBoxIcon.Error);

				// Exit with -1 code
				Environment.Exit(-1);
			}
			else
			{
				// Startup application
				Application.EnableVisualStyles();
				Application.SetCompatibleTextRenderingDefault(false);
				Application.Run(new MainForm());
			}
		}
	}
}